package first.codeTop.alibaba;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName LC144
 * @description:
 * @author: 荣燊
 * @create: 2021-10-16 12:57
 **/
public class LC144 {
    public static void main(String[] args) {


    }

    ArrayList<Integer> list = new ArrayList<>();

    public List<Integer> preorderTraversal(TreeNode root) {
        dfs(root);
        return list;
    }

    public void dfs(TreeNode root) {
        if (root == null) {
            return;
        }
        list.add(root.val);
        dfs(root.left);
        dfs(root.right);
    }


}
